# Copyright(c) 2008 Tri Tech Information Systems Inc. 
# Distributed under the Boost Software License, Version 1.0.
#     (See accompanying file ../../LICENSE_1_0.txt or copy at
#           http://www.boost.org/LICENSE_1_0.txt)
#     
def destruction():
    """
    These tests do various things to make sure that
    QObjects are cleaned up when they are supposed to be

    If we lose references to the parent first,
    both parent and child are destroyed
    >>> from qt3 import *
    >>> o = PlayObject()
    PlayObject constructed
    >>> p = PlayObject(o)
    PlayObject constructed
    >>> del o
    PlayObject destroyed
    PlayObject destroyed
    >>> del p

    If we lose reference to the child, nothing happens
    Both will be destroyed when we lose the parent
    >>> o = PlayObject()
    PlayObject constructed
    >>> p = PlayObject(o)
    PlayObject constructed
    >>> del p
    >>> del o
    PlayObject destroyed
    PlayObject destroyed
    """

def shell_game_test():
    """
    >>> from qt3 import *
    
    The shell_game function simply returns whatever you pass to it
    We use this to test some c++/python passing

    Firstly, it takes and returns a QObject, yet we should
    Find the most derived type
    >>> o = PlayObject()
    PlayObject constructed
    >>> shell_game(o)
    <qt3.PlayObject object at 0x...>
    
    Secondly, we should get the same python object
    back as we send in
    >>> p = shell_game(o)
    >>> p is o
    True

    Make sure we cleanup
    >>> del o
    >>> del p
    PlayObject destroyed
    """

if __name__ == '__main__':
    import doctest
    import sys
    sys.exit(doctest.testmod(optionflags=doctest.ELLIPSIS)[0])
